package com.me.shop.product.action;

import javax.swing.plaf.basic.BasicSliderUI.ActionScroller;

import com.me.shop.product.bean.Product;
import com.me.shop.product.service.ProductService;
import com.me.shop.utils.PageBean;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class ProductAction extends ActionSupport implements ModelDriven<Product> {
	
	private Product product = new Product();
	public Product getModel() {
		return product;
	}
	
	private Integer cid;
	public void setCid(Integer cid) {
		this.cid = cid;
	}
	public Integer getCid() {
		return cid;
	}
	
	private Integer csid;
	public Integer getCsid() {
		return csid;
	}
	public void setCsid(Integer csid) {
		this.csid = csid;
	}

	private int page;
	public void setPage(int page) {
		this.page = page;
	}
	
	ProductService productService;
	public void setProductService(ProductService productService) {
		this.productService = productService;
	}
	
	public String findByPid() { // 因为modelDriven<Product> 所以取数据可以直接在jsp页面中使用       model。  来取出数据
		product = productService.findByPid(product.getPid());
		return "findByPid";
	}
	
	public String findByCid() {
		PageBean<Product> pageBean = productService.findByPageCid(cid,page);
		ActionContext.getContext().getValueStack().set("pageBean", pageBean);
		return "findByCid";
	}
		
	public String findByCsid() {
		PageBean<Product> pageBean = productService.findByCsid(csid,page);
		ActionContext.getContext().getValueStack().set("pageBean", pageBean);
		return "findByCsid";
	}
	
}	


















